package com.mpgame.core.model;

import com.fasterxml.jackson.databind.JsonNode;

import lombok.Data;

@Data
public class Damage {
    private final DamageType type;
    private final int amount;

    public static Damage parseFromJson(JsonNode params){
        String type = params.get("type").asText();
        int amount = params.get("amount").asInt();
        DamageType dmgType = DamageType.FIXED;
        if(type == "melee") dmgType = DamageType.MELEE; else if(type == "magic") dmgType = DamageType.MAGIC;
        return new Damage(dmgType, amount);
    }
}
